package com.su.lightthings.utils

import android.content.Context
import android.media.AudioManager
import com.su.lightthings.base.BaseApplication

object AudioUtil {
    /**
     * 控制音量
     * @param type 1：音量减 ， 2：音量加
     */
    fun controlVolume(type: Int) {
        val am = BaseApplication.instance.getSystemService(Context.AUDIO_SERVICE) as AudioManager
        val direction = when (type) {
            1 -> AudioManager.ADJUST_LOWER
            2 -> AudioManager.ADJUST_RAISE
            else -> AudioManager.ADJUST_SAME
        }
        am.adjustStreamVolume(AudioManager.STREAM_MUSIC, direction, AudioManager.FLAG_SHOW_UI)
    }
}